<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Customer extends CI_Controller {

    /**
     * Index action 
     * @author tien.nguyen
     */
    public function index() {
        //instance model
        $this->load->model('Customers', '', true);     
        $this->load->model('Categories', null, true);

        //load data by model 
        $data['Customers'] = $this->Customers->getListCustomer();
        $data['CustomersCates'] = $this->Customers->getListCustomerFlowCate();
        $data['OptionCategories'] = $this->Categories->getOptions();
        $this->load->view('customer/index', $data);
    }
    
    public function detailAjax($customerId){
        $this->load->model('Customers', '', true);
        $this->load->model('Customervideos', '', true);
        
        //load new detail
        //load data by model 
        $data['Customer'] = $this->Customers->getCustomer($customerId);
        //$data['Videos'] = $this->Customervideos->getListCustomerDetail($customerId);
        echo json_encode($data);
        header('Content-type: application/json');
        die;
    }
    
    public function detail($customerId){
        $this->load->model('Customers', '', true);
        $this->load->model('Customervideos', '', true);
        
        //load new detail
        //load data by model 
        $data['Customer'] = $this->Customers->getCustomer($customerId);
        $data['Videos'] = $this->Customervideos->getListCustomerDetail($customerId);
               
        $this->load->view('customer/detail', $data);
    }

}